Skip to content

feat: Create actual indexes and fix up state + error logic CLOUDP-317945 #6933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

rubydong
Copy link
Collaborator

@rubydong rubydong commented May 19, 2025

Description

Had to re-enable the button always to get this error to show up -- normally there's validation so user won't be able to click on the button in the first place with parsing errors
image
image

Also mocked this error by manipulating the # of rows. It is unlikely for the user to encounter this normally.
image
image

Drive-by fixes to open from nudge styling + lint
image

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@rubydong rubydong changed the title Cloudp 317945 feat: Create actual indexes and fix up state + error logic CLOUDP-317945 May 19, 2025
@github-actions github-actions bot added the feat label May 19, 2025
@rubydong rubydong added the no release notes Fix or feature not for release notes label May 19, 2025
@rubydong rubydong marked this pull request as ready for review May 20, 2025 17:23
@rubydong rubydong added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label May 20, 2025
Comment on lines 151 to 162
let isShowSuggestionsButtonDisabled = !hasNewChanges;

// Validate query upon typing
try {
parseFilter(inputQuery);

if (!inputQuery.startsWith('{') || !inputQuery.endsWith('}')) {
isShowSuggestionsButtonDisabled = true;
}
} catch (e) {
isShowSuggestionsButtonDisabled = true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: parsing the query on every re-render seems a big too excessive, let's pack this logic inside a useMemo

@@ -104,10 +106,13 @@ const QueryFlowSection = ({
}: SuggestedIndexFetchedProps) => Promise<void>;
indexSuggestions: Record<string, number> | null;
fetchingSuggestionsState: IndexSuggestionState;
initialQuery: Document | null;
initialQuery: string | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is incorrect (as the JSON.stringify that you still keep below indicates), you're still getting a document here, not a string, why the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right -- i was trying to fix the type but messed it up along the way. i fixed it!

: 'Error parsing query. Please follow query structure.',
indexSuggestionsState: 'error',
});
track('Error parsing query', { context: 'Create Index Modal' });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add TODOs that point to a ticket for cleaning up these non real tracking events, I think you mentioned that there is one that should be part of the project

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added TODOs and yes these will be cleaned up in wrap-up

@gribnoysup
Copy link
Collaborator

(merged main to see if CI failures are unrelated to changes here)

@@ -343,7 +339,7 @@ function getInitialState(): State {

//-------

export const createIndexOpened = (query?: BsonDocument) => ({
export const createIndexOpened = (query?: Document) => ({
Copy link
Collaborator

@gribnoysup gribnoysup May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that both you and @waltertan12 added an import here from two different packages, but this points to the same type, so this change is not really doing anything and it seems confusing to have both. Can you leave just one, either Document or BsonDocument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@gribnoysup
Copy link
Collaborator

CI failures seem related to your changes as they are failing in the compass-indexes package, can you take a look?

@rubydong
Copy link
Collaborator Author

CI failures seem related to your changes as they are failing in the compass-indexes package, can you take a look?

yes thanks for checking and pulling in master. i updated a test to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants